<template>
  <div>
    <zh-card title="">
      <zh-form :model="pageData.queryParams" ref="queryFormRef">
<!--        <zh-form-input prop="ruleId" label="字段校验规则主键" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.ruleId"></zh-form-input>-->
        <zh-form-input prop="message" label="校验失败提示" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.message"></zh-form-input>
<!--        <zh-form-input prop="fieldId" label="字段主键" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.fieldId"></zh-form-input>-->
        <zh-form-input prop="fieldName" label="字段名称" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.fieldName"></zh-form-input>
        <zh-form-select prop="validFieldType" label="校验字段类型" allowClear :options="pageData.dictData.VALIDFIELDTYPE"
                        v-model="pageData.queryParams.validFieldType"></zh-form-select>
        <zh-form-select prop="validRuleType" label="校验规则类型" allowClear :span="8"
                        :options="pageData.dictData.VALIDRULETYPE"
                        v-model="pageData.queryParams.validRuleType"></zh-form-select>
<!--        <zh-form-input prop="validNull" label="是否为空" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validNull"></zh-form-input>
        <zh-form-input prop="validNotnull" label="是否不为空" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validNotnull"></zh-form-input>
        <zh-form-input prop="validTrue" label="是否为真" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validTrue"></zh-form-input>-->
        <!--        <zh-form-input prop="validFalse" label="是否为假" type="text" :span="8" dataType="common"
                               v-model="pageData.queryParams.validFalse"></zh-form-input>-->
        <zh-form-input prop="validMin" label="数字 最小值" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validMin"></zh-form-input>
        <zh-form-input prop="validMax" label="数字 最大值" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validMax"></zh-form-input>
        <zh-form-input prop="validDecimalMin" label="实数 最小值" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validDecimalMin"></zh-form-input>
        <zh-form-input prop="validDecimalMax" label="实数 最大值" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validDecimalMax"></zh-form-input>
        <zh-form-input prop="validSizeMin" label="集合 最小值" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validSizeMin"></zh-form-input>
        <zh-form-input prop="validSizeMax" label="集合 最大值" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validSizeMax"></zh-form-input>
        <zh-form-input prop="validDigitsFraction" label="数字 小数位数" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validDigitsFraction"></zh-form-input>
        <zh-form-input prop="validDigitsInteger" label="数字 整数位数" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validDigitsInteger"></zh-form-input>
<!--        <zh-form-input prop="validNotEmpty" label="字符串 不为空字符串" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validNotEmpty"></zh-form-input>
        <zh-form-input prop="validEmail" label="是否邮箱" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validEmail"></zh-form-input>-->
        <zh-form-input prop="validPattern" label="正则校验" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validPattern"></zh-form-input>
        <zh-form-input prop="validClass" label="自定义校验类" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.validClass"></zh-form-input>
        <zh-form-query @queryClick="queryFieldValidRule" :formRef="queryFormRef" :show-advanced="false">
          <el-button @click="showAddDialog">添加</el-button>
        </zh-form-query>
      </zh-form>
    </zh-card>
    <zh-table title="字段校验规则列表" ref="fieldValidRuleTable"
              size="mini"
              :funcCode="'fieldValidRule0001'"
              :columns="pageData.tableColumns"
              highlight-current-row>
      <template #op="scope">
        <el-tooltip content="编辑" placement="top">
          <el-button :icon="Edit" link @click="showEditDialog(scope)"></el-button>
        </el-tooltip>
        <el-tooltip content="删除" placement="top">
          <el-button :icon="Delete" type="danger" link @click="delFieldValidRule(scope.row)"></el-button>
        </el-tooltip>
        <el-tooltip content="详情" placement="top">
          <el-button :icon="Document" link @click="showDetail(scope)"></el-button>
        </el-tooltip>
      </template>
    </zh-table>
    <el-dialog title="添加字段校验规则" v-model="pageData.addFieldValidRuleDialogVisible" width="1200">
      <zh-card title="添加信息">
        <zh-form :rules="pageData.formRules" :model="formData">
          <!--        <zh-form-input prop="ruleId" label="字段校验规则主键" type="text" :span="8" dataType="common"
                                 v-model="pageData.formData.ruleId"></zh-form-input>-->
          <zh-form-input prop="message" label="校验失败提示" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.message"></zh-form-input>
          <!--        <zh-form-input prop="fieldId" label="字段主键" type="text" :span="8" dataType="common"
                                 v-model="pageData.formData.fieldId"></zh-form-input>-->
          <zh-form-input prop="fieldName" label="字段名称" type="text" :span="8" dataType="common" disabled
                         v-model="pageData.formData.fieldName"></zh-form-input>
          <zh-form-select prop="validFieldType" label="校验字段类型" allowClear :span="8" :options="pageData.dictData.VALIDFIELDTYPE"
                          v-model="pageData.formData.validFieldType"></zh-form-select>
          <zh-form-select prop="validRuleType" label="校验规则类型" allowClear :span="8"
                          :options="pageData.dictData.VALIDRULETYPE"
                          v-model="pageData.formData.validRuleType"></zh-form-select>
          <!--        <zh-form-input prop="validNull" label="是否为空" type="text" :span="8" dataType="common"
                                 v-model="pageData.formData.validNull"></zh-form-input>
                  <zh-form-input prop="validNotnull" label="是否不为空" type="text" :span="8" dataType="common"
                                 v-model="pageData.formData.validNotnull"></zh-form-input>
                  <zh-form-input prop="validTrue" label="是否为真" type="text" :span="8" dataType="common"
                                 v-model="pageData.formData.validTrue"></zh-form-input>
                  <zh-form-input prop="validFalse" label="是否为假" type="text" :span="8" dataType="common"
                                 v-model="pageData.formData.validFalse"></zh-form-input>-->
          <zh-form-input prop="validMin" label="数字 最小值" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validMin"></zh-form-input>
          <zh-form-input prop="validMax" label="数字 最大值" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validMax"></zh-form-input>
          <zh-form-input prop="validDecimalMin" label="实数 最小值" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validDecimalMin"></zh-form-input>
          <zh-form-input prop="validDecimalMax" label="实数 最大值" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validDecimalMax"></zh-form-input>
          <zh-form-input prop="validSizeMin" label="集合 最小值" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validSizeMin"></zh-form-input>
          <zh-form-input prop="validSizeMax" label="集合 最大值" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validSizeMax"></zh-form-input>
          <zh-form-input prop="validDigitsInteger" label="数字 整数位数" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validDigitsInteger"></zh-form-input>
          <zh-form-input prop="validDigitsFraction" label="数字 小数位数" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validDigitsFraction"></zh-form-input>
          <!--        <zh-form-input prop="validNotEmpty" label="字符串 不为空字符串" type="text" :span="8" dataType="common"
                                 v-model="pageData.formData.validNotEmpty"></zh-form-input>
                  <zh-form-input prop="validEmail" label="是否邮箱" type="text" :span="8" dataType="common"
                                 v-model="pageData.formData.validEmail"></zh-form-input>-->
          <zh-form-input prop="validPattern" label="正则校验" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validPattern"></zh-form-input>
          <zh-form-input prop="validClass" label="自定义校验类" type="text" :span="8" dataType="common"
                         v-model="pageData.formData.validClass"></zh-form-input>
        </zh-form>
      </zh-card>
      <zh-card title="">
        <zh-form :model="pageData.logicTableFieldQueryParams" ref="logicTableQueryFormRef">
          <zh-form-input prop="tableName" label="表格名称" type="text" :span="8" dataType="common"
                         v-model="pageData.logicTableFieldQueryParams.tableName"></zh-form-input>
          <zh-form-input prop="dataSourcename" label="数据源名称" type="text" :span="8" dataType="common"
                         v-model="pageData.logicTableFieldQueryParams.dataSourcename"></zh-form-input>
          <template v-if="pageData.logicTableQueryAdvanced">
            <zh-form-input prop="srcTableName" label="源表格名称" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.srcTableName"></zh-form-input>
            <zh-form-input prop="srcColumnType" label="源字段类型" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.srcColumnType"></zh-form-input>
            <zh-form-input prop="srcColumnName" label="源字段名称" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.srcColumnName"></zh-form-input>
            <zh-form-input prop="mapTableName" label="映射逻辑表格名称" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.mapTableName"></zh-form-input>
            <zh-form-input prop="mapColumnType" label="映射字段类型" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.mapColumnType"></zh-form-input>
            <zh-form-input prop="mapColumnName" label="映射字段名称" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.mapColumnName"></zh-form-input>
          </template>
          <zh-form-query v-model="pageData.logicTableQueryAdvanced" :form-ref="logicTableQueryFormRef" :table-ref="logicTableFieldMapTable"
              @queryClick="() => {logicTableFieldMapTable.query({...pageData.logicTableFieldQueryParams})}" :formRef="queryFormRef">
          </zh-form-query>
        </zh-form>
      </zh-card>
      <zh-table title="逻辑表字段映射列表" ref="logicTableFieldMapTable" height="300"
                size="mini"
                :funcCode="'logicTableFieldMap0001'"
                :columns="pageData.logicTableFieldTableColumns"
                @click="() => {
                  pageData.formData.fieldId = logicTableFieldMapTable.getCurrentRecord().mapColumnId;
                  pageData.formData.fieldName = logicTableFieldMapTable.getCurrentRecord().mapColumnName;
                }"
                highlight-current-row>
      </zh-table>
      <template #footer>
          <span class="dialog-footer">

            <el-button @click="pageData.addFieldValidRuleDialogVisible = false">取消</el-button>
            <el-button type="primary" @click="addFieldValidRule">
              保存
            </el-button>
          </span>
      </template>
    </el-dialog>
    <el-dialog title="修改字段校验规则" v-model="pageData.editFieldValidRuleDialogVisible">
      <zh-card>
        <zh-form :rules="pageData.formRules" :model="pageData.editFormData">
<!--        <zh-form-input prop="ruleId" label="字段校验规则主键"
                       v-model="pageData.editFormData.ruleId"></zh-form-input>-->
        <zh-form-input prop="message" label="校验失败提示"
                       v-model="pageData.editFormData.message"></zh-form-input>
<!--        <zh-form-input prop="fieldId" label="字段主键"-->
<!--                       v-model="pageData.editFormData.fieldId"></zh-form-input>-->
        <zh-form-input prop="fieldName" label="字段名称" disabled
                       v-model="pageData.editFormData.fieldName"></zh-form-input>
        <zh-form-select prop="validFieldType" label="校验字段类型" allowClear :options="pageData.dictData.VALIDFIELDTYPE"
                       v-model="pageData.editFormData.validFieldType"></zh-form-select>
        <zh-form-select prop="validRuleType" label="校验规则类型" allowClear :options="pageData.dictData.VALIDRULETYPE"
                        v-model="pageData.editFormData.validRuleType"></zh-form-select>
<!--        <zh-form-input prop="validNull" label="是否为空"
                       v-model="pageData.editFormData.validNull"></zh-form-input>
        <zh-form-input prop="validNotnull" label="是否不为空"
                       v-model="pageData.editFormData.validNotnull"></zh-form-input>
        <zh-form-input prop="validTrue" label="是否为真"
                       v-model="pageData.editFormData.validTrue"></zh-form-input>
        <zh-form-input prop="validFalse" label="是否为假"
                       v-model="pageData.editFormData.validFalse"></zh-form-input>-->
        <zh-form-input prop="validMin" label="数字 最小值"
                       v-model="pageData.editFormData.validMin"></zh-form-input>
        <zh-form-input prop="validMax" label="数字 最大值"
                       v-model="pageData.editFormData.validMax"></zh-form-input>
        <zh-form-input prop="validDecimalMin" label="实数 最小值"
                       v-model="pageData.editFormData.validDecimalMin"></zh-form-input>
        <zh-form-input prop="validDecimalMax" label="实数 最大值"
                       v-model="pageData.editFormData.validDecimalMax"></zh-form-input>
        <zh-form-input prop="validSizeMin" label="集合 最小值"
                       v-model="pageData.editFormData.validSizeMin"></zh-form-input>
        <zh-form-input prop="validSizeMax" label="集合 最大值"
                       v-model="pageData.editFormData.validSizeMax"></zh-form-input>
        <zh-form-input prop="validDigitsInteger" label="数字 整数位数"
                       v-model="pageData.editFormData.validDigitsInteger"></zh-form-input>
        <zh-form-input prop="validDigitsFraction" label="数字 小数位数"
                       v-model="pageData.editFormData.validDigitsFraction"></zh-form-input>
<!--        <zh-form-input prop="validNotEmpty" label="字符串 不为空字符串"
                       v-model="pageData.editFormData.validNotEmpty"></zh-form-input>
        <zh-form-input prop="validEmail" label="是否邮箱"
                       v-model="pageData.editFormData.validEmail"></zh-form-input>-->
        <zh-form-input prop="validPattern" label="正则校验"
                       v-model="pageData.editFormData.validPattern"></zh-form-input>
        <zh-form-input prop="validClass" label="自定义校验类"
                       v-model="pageData.editFormData.validClass"></zh-form-input>
      </zh-form>
      </zh-card>
      <zh-card title="">
        <zh-form :model="pageData.logicTableFieldQueryParams" ref="logicTableQueryFormRef">
          <zh-form-input prop="tableName" label="表格名称" type="text" :span="8" dataType="common"
                         v-model="pageData.logicTableFieldQueryParams.tableName"></zh-form-input>
          <zh-form-input prop="dataSourcename" label="数据源名称" type="text" :span="8" dataType="common"
                         v-model="pageData.logicTableFieldQueryParams.dataSourcename"></zh-form-input>
          <template v-if="pageData.logicTableQueryAdvanced">
            <zh-form-input prop="srcTableName" label="源表格名称" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.srcTableName"></zh-form-input>
            <zh-form-input prop="srcColumnType" label="源字段类型" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.srcColumnType"></zh-form-input>
            <zh-form-input prop="srcColumnName" label="源字段名称" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.srcColumnName"></zh-form-input>
            <zh-form-input prop="mapTableName" label="映射逻辑表格名称" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.mapTableName"></zh-form-input>
            <zh-form-input prop="mapColumnType" label="映射字段类型" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.mapColumnType"></zh-form-input>
            <zh-form-input prop="mapColumnName" label="映射字段名称" type="text" :span="8" dataType="common"
                           v-model="pageData.logicTableFieldQueryParams.mapColumnName"></zh-form-input>
          </template>
          <zh-form-query v-model="pageData.logicTableQueryAdvanced" :form-ref="logicTableQueryFormRef" :table-ref="logicTableFieldMapTable"
                         @queryClick="() => {logicTableFieldMapTable.query({...pageData.logicTableFieldQueryParams})}" :formRef="queryFormRef">
          </zh-form-query>
        </zh-form>
      </zh-card>
      <zh-table title="逻辑表字段映射列表" ref="logicTableFieldMapTable" height="300"
                size="mini"
                :funcCode="'logicTableFieldMap0001'"
                :columns="pageData.logicTableFieldTableColumns"
                @click="() => {
                  pageData.editFormData.fieldId = logicTableFieldMapTable.getCurrentRecord().mapColumnId;
                  pageData.editFormData.fieldName = logicTableFieldMapTable.getCurrentRecord().mapColumnName;
                }"
                highlight-current-row>
      </zh-table>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="pageData.editFieldValidRuleDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="editFieldValidRule">
            保存
          </el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script lang="ts" setup name="fieldValidRule">
import {Delete, Edit, Document} from '@element-plus/icons-vue'
import {ElMessageBox} from "element-plus";
// ------------------接收传入参数(组件)-------------------

// ------------------钩子函数----------------------------
// 初始化
onMounted(() => {
  init();
})

// ------------------定义子组件--------------------------
const fieldValidRuleTable = ref();
const queryFormRef = ref();
const logicTableQueryFormRef = ref();
const logicTableFieldMapTable = ref();
// ------------------变量区------------------------------
const pageData = reactive({
  addFieldValidRuleDialogVisible: false,
  editFieldValidRuleDialogVisible: false,
  detailDialog: false,
  tableColumns: [
    {type: 'seq', width: 60, fixed: 'left', align: 'center', title: '序号'},
    {field: 'ruleId', title: '字段校验规则主键', visible: false, align: 'center', width: 100},
    {field: 'message', title: '校验失败提示', visible: true, align: 'center', width: 100},
    {field: 'fieldId', title: '字段主键', visible: false, align: 'center', width: 100},
    {field: 'fieldName', title: '字段名称', visible: true, align: 'center', width: 100},
    {field: 'validFieldType', title: '校验字段类型 1-数字 2-字符串 3-集合', visible: false, align: 'center', width: 100},
    {field: 'validFieldTypeName', title: '校验字段类型', visible: true, align: 'center', width: 100},
    {field: 'validRuleType', title: '校验规则类型', visible: false, align: 'center', width: 100},
    {field: 'validRuleTypeName', title: '校验规则类型', visible: true, align: 'center', width: 100},
    {field: 'validNull', title: '是否为空', visible: false, align: 'center', width: 100},
    {field: 'validNotnull', title: '是否不为空', visible: false, align: 'center', width: 100},
    {field: 'validTrue', title: '是否为真', visible: false, align: 'center', width: 100},
    {field: 'validFalse', title: '是否为假', visible: false, align: 'center', width: 100},
    {field: 'validMin', title: '数字 最小值', visible: true, align: 'center', width: 100},
    {field: 'validMax', title: '数字 最大值', visible: true, align: 'center', width: 100},
    {field: 'validDecimalMin', title: '实数 最小值', visible: true, align: 'center', width: 100},
    {field: 'validDecimalMax', title: '实数 最大值', visible: true, align: 'center', width: 100},
    {field: 'validSizeMin', title: '集合 最小值', visible: true, align: 'center', width: 100},
    {field: 'validSizeMax', title: '集合 最大值', visible: true, align: 'center', width: 100},
    {field: 'validDigitsFraction', title: '数字 小数位数', visible: true, align: 'center', width: 100},
    {field: 'validDigitsInteger', title: '数字 整数位数', visible: true, align: 'center', width: 100},
    {field: 'validNotEmpty', title: '字符串 不为空字符串', visible: false, align: 'center', width: 100},
    {field: 'validEmail', title: '是否邮箱', visible: false, align: 'center', width: 100},
    {field: 'validPattern', title: '正则校验', visible: true, align: 'center', width: 100},
    {field: 'validClass', title: '自定义校验类', visible: true, align: 'center', width: 100},
    {field: 'op', title: '操作', visible: true, align: 'center', width: 100, fixed: 'right', slots: {default: 'op'}},
  ],
  queryParams: {
    ruleId: '',
    message: '',
    fieldId: '',
    fieldName: '',
    validFieldType: '',
    validRuleType: '',
    validNull: '',
    validNotnull: '',
    validTrue: '',
    validMin: '',
    validFalse: '',
    validMax: '',
    validDecimalMin: '',
    validSizeMin: '',
    validDecimalMax: '',
    validSizeMax: '',
    validDigitsFraction: '',
    validDigitsInteger: '',
    validNotEmpty: '',
    validEmail: '',
    validPattern: '',
    validClass: ''
  },
  formData: {
    ruleId: '',
    message: '',
    fieldId: '',
    fieldName: '',
    validFieldType: '',
    validRuleType: '',
    validNull: '',
    validNotnull: '',
    validTrue: '',
    validMin: '',
    validFalse: '',
    validMax: '',
    validDecimalMin: '',
    validSizeMin: '',
    validDecimalMax: '',
    validSizeMax: '',
    validDigitsFraction: '',
    validDigitsInteger: '',
    validNotEmpty: '',
    validEmail: '',
    validPattern: '',
    validClass: ''
  },
  editFormData: {
    ruleId: '',
    message: '',
    fieldId: '',
    fieldName: '',
    validFieldType: '',
    validRuleType: '',
    validNull: '',
    validNotnull: '',
    validTrue: '',
    validMin: '',
    validFalse: '',
    validMax: '',
    validDecimalMin: '',
    validSizeMin: '',
    validDecimalMax: '',
    validSizeMax: '',
    validDigitsFraction: '',
    validDigitsInteger: '',
    validNotEmpty: '',
    validEmail: '',
    validPattern: '',
    validClass: ''
  },
  formRules: {},
  dictFields: 'VALIDRULETYPE,VALIDFIELDTYPE',
  dictData: [],
  logicTableQueryAdvanced: false,
  logicTableFieldTableColumns: [
    {type: 'seq', width: 60, fixed: 'left', align: 'center', title: '序号'},
    // {field: 'fieldMapId', title: '表格字段映射主键', visible: true, align: 'center', width: 100},
    {field: 'tableName', title: '表格名称', visible: true, align: 'center', width: 150},
    // {field: 'datasourceId', title: '所属数据源', visible: true, align: 'center', width: 100},
    {field: 'dataSourcename', title: '数据源名称', visible: true, align: 'center', width: 100},
    // {field: 'mapTableId', title: '映射逻辑表格id', visible: true, align: 'center', width: 100},
    {field: 'mapTableName', title: '映射逻辑表格名称', visible: true, align: 'center', width: 150},
    // {field: 'mapColumnId', title: '映射字段id', visible: true, align: 'center', width: 100},
    {field: 'mapColumnName', title: '映射字段名称', visible: true, align: 'center', width: 100},
    {field: 'mapColumnType', title: '映射字段类型', visible: true, align: 'center', width: 100},
    // {field: 'srcTableId', title: '源表格表id', visible: true, align: 'center', width: 100},
    {field: 'srcTableName', title: '源表格名称', visible: true, align: 'center', width: 150},
    // {field: 'srcColumnId', title: '源字段id', visible: true, align: 'center', width: 100},
    {field: 'srcColumnName', title: '源字段名称', visible: true, align: 'center', width: 100},
    {field: 'srcColumnType', title: '源字段类型', visible: true, align: 'center', width: 100},
  ],
  logicTableFieldQueryParams: {
    fieldMapId: '',
    tableName: '',
    datasourceId: '',
    dataSourcename: '',
    srcTableId: '',
    srcTableName: '',
    srcColumnId: '',
    srcColumnType: '',
    srcColumnName: '',
    mapTableId: '',
    mapTableName: '',
    mapColumnId: '',
    mapColumnType: '',
    mapColumnName: ''
  },
});
// ------------------方法区------------------------------
const init = () => {
  getDict();
  queryFieldValidRule();
}
// 查询数据字典信息
const getDict = () => {
  let params = {
    dictFields: pageData.dictFields,
  };
  $api.common.getBatchDict.post(params).then((res: any) => {
    pageData.dictData = res.result;
  });
};
const queryFieldValidRule = () => {
  fieldValidRuleTable.value.query(pageData.queryParams);
}
const showAddDialog = () => {
  pageData.addFieldValidRuleDialogVisible = true;
  pageData.formData = {
    ruleId: '',
    message: '',
    fieldId: '',
    fieldName: '',
    validFieldType: '',
    validRuleType: '',
    validNull: '',
    validNotnull: '',
    validTrue: '',
    validMin: '',
    validFalse: '',
    validMax: '',
    validDecimalMin: '',
    validSizeMin: '',
    validDecimalMax: '',
    validSizeMax: '',
    validDigitsFraction: '',
    validDigitsInteger: '',
    validNotEmpty: '',
    validEmail: '',
    validPattern: '',
    validClass: ''
  }
}
const showEditDialog = (scope) => {
  pageData.editFieldValidRuleDialogVisible = true;
  pageData.editFormData = {...scope.row}
}
const addFieldValidRule = () => {
  $api.common.send.post('fieldValidRule0004', pageData.formData).then(res => {
    if (res.code == 0) {
      ElMessageBox.alert('添加字段校验规则成功');
      pageData.addFieldValidRuleDialogVisible = false;
      queryFieldValidRule();
    }
  })
}
const editFieldValidRule = () => {
  $api.common.send.post('fieldValidRule0005', pageData.editFormData).then(res => {
    if (res.code == 0) {
      ElMessageBox.alert('修改字段校验规则成功');
      pageData.editFieldValidRuleDialogVisible = false;
      queryFieldValidRule();
    }
  })
}
const delFieldValidRule = ({ruleId}) => {
  ElMessageBox.confirm('确定删除该字段校验规则?').then(() => {
    $api.common.send.post('fieldValidRule0006', {ruleId: ruleId}).then(res => {
      if (res.code == 0) {
        ElMessageBox.alert('删除字段校验规则成功');
        queryFieldValidRule();
      }
    })
  })
}

</script>
<style lang="scss" scoped></style>
